﻿using System;
using System.Reflection;
using BlankMvc.Dao.Attributes;
using BlankMvc.Dao.Repository.Base;

namespace BlankMvc.Dao {
	public static class UnitOfWorkHelper {
		public static bool IsRepositoryMethod(MethodInfo methodInfo) {
			return IsRepositoryClass(methodInfo.DeclaringType);
		}

		public static bool IsRepositoryClass(Type type) {
			return typeof(IRepository).IsAssignableFrom(type);
		}

		public static bool HasUnitOfWorkAttribute(MethodInfo methodInfo) {
			return methodInfo.IsDefined(typeof(UnitOfWorkAttribute), true);
		}
	}
}
